
--[[
	*******************
	* MCServer Plugin *
	*******************
	Author: thomasfn
	Name: freestuff
	Description: Provides free stuff chat commands
--]]

local plugin = {}

local kits = {
	tool = { 269, 270, 271 }, -- Wooden spade, pick, axe
	explorer = { 345, 347 }, -- Compass, watch
	coal = { 263, 263, 263, 263 } -- Coal x4
}

local function TeachSyntax( ply )
	local tmp = {}
	for name, data in pairs( kits ) do
		table.insert( tmp, name )
	end
	ply:SendChat( "Syntax: /free <" .. table.concat( tmp, "," ) .. ">" )
end

function plugin.PlayerChatCommand( ply, cmd, args )
	if (cmd == "free") then
		if (args[1]) then
			if (kits[ args[1] ]) then
				for i=1, #kits[ args[1] ] do
					ply:GiveItem( kits[ args[1] ][i], 1, 0 )
				end
				ply:SendChat( "Enjoy your free " .. COL_DARKGREEN .. args[1] .. COL_WHITE .. " kit!" )
			else
				TeachSyntax( ply )
			end
		else
			TeachSyntax( ply )
		end
		return true
	end
end

function plugin.ListChatCommands( tmp )
	tmp:Add( "/free" )
end

hooks.Add( "freestuff", plugin )